<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>我是div</div>
    <span>我是span</span>
    <ul>
        <li>我是li</li>
        <li>我是li</li>
        <li>我是li</li>
        <li>我是li</li>
    </ul>
    <div class="demo">
        <div class="box">
            <span class="erweima">x</span>
        </div>
    </div>
    <ol>
        <li>我是li1</li>
        <li>我是li2</li>
        <li>我是li3</li>
        <li>我是li4</li>
    </ol>
    <script>
        var box = document.querySelector('.box');
        var erweima = document.querySelector('.erweima');
        console.dir(box);
        //得到的是离元素最近的父级节点 找不到父节点返回 null
        console.log(erweima.parentNode);

        var ul = document.querySelector('ul');
        var lis = ul.querySelectorAll('li');
        console.log(ul.childNodes);
        console.log(ul.children);

        var ol = document.querySelector('ol');
        console.log(ol.firstChild);
        console.log(ol.lastChild);
        console.log(ol.firstElementChild);
        console.log(ol.lastElementChild);
        console.log(ol.children[0]);
        console.log(ol.children[3]);
    </script>
</body>

</html>